package com.sinoglobal.ningxia.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Window;
import android.widget.TextView;

import com.sinoglobal.ningxia.R;

public class MyProgressDialog extends Dialog {
	private TextView text,progress_text;
	private MyProgress progress;

	private String message = "您好!";// 提示信息


	public MyProgressDialog(Context context) {
		super(context);
	}
	
	public MyProgressDialog(Context context,String message) {
		super(context);
		this.message = message;
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.progress_dialog);
		initView();
	}

	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	
	private void initView() {
//		LinearLayout v= (LinearLayout)findViewById(R.id.dialog);
//		LinearLayout.LayoutParams imagebtn_params = new LinearLayout.LayoutParams(
//				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
//			imagebtn_params.width = FlyApplication.widthPixels *2/ 3;
//		v.setLayoutParams(imagebtn_params);
		text = (TextView) findViewById(R.id.progress_tittle);
		progress_text = (TextView) findViewById(R.id.progress_text);
		progress_text.setText("0%          ");
		text.setText(message);
		progress = (MyProgress) findViewById(R.id.Button0002);
	}
	
	public void setProgress(int i){
		progress.setProgress(i);
		int j = (i * 100) / progress.getMax();
		String textp = String.valueOf(j) + "%          ";
		progress_text.setText(textp);
		progress.invalidate();
		progress_text.invalidate();
	}

	public void setMax(int i){
		progress.setMax(i);
	}

	public int getMax(){
		return progress.getMax();
	}

}
